/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package travelexperts;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jdesktop.beansbinding.Converter;

/**
 *
 * @author Administrator
 */
    public class Convert extends Converter<Date, String> {

    @Override
    public String convertForward(Date arg) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String dateStr = sdf.format(arg);
        return dateStr;
    }

    @Override
    public Date convertReverse(String arg) {
        Date value=null;
        try {
            value = (arg == null) ? null : (new SimpleDateFormat("yyyy-MM-dd").parse(arg));
        } catch (NumberFormatException ex) {
            value = null;
        } catch (ParseException ex) {
            Logger.getLogger(Convert.class.getName()).log(Level.SEVERE, null, ex);
        }
        return value;
    }
}

